package me.zhenqu.model.dao.impl;

import me.zhenqu.model.pojo.entity.User;
import me.zhenqu.model.dao.UserDao;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository("userDao")
public class UserDaoImpl extends ZhenquDaoHelper<User> implements UserDao {

    @Override
    public User findByID(Long user_id) {
        List list = getHibernateTemplate().find("from User where user_id=?",user_id);
        if (list==null||list.isEmpty()) return null;
		return (User)list.get(0);
    }

    public User findByNickName(String nick_name) {
        List list = getHibernateTemplate().find("from User where nick_name=?",nick_name);
        if (list==null||list.isEmpty()) return null;
		return (User)list.get(0);
    }

    @Override
    public List<User> search(String keyword) {
        List list = getHibernateTemplate().find("from User where nick_name like ?",'%' + keyword + '%');
        return list;
    }
}